package com.ruoyi.tranShort.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.tranShort.domain.ShortSentryPost;
import com.ruoyi.tranShort.service.IShortSentryPostService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 哨位管理Controller
 * 
 * @author ruoyi
 * @date 2021-08-13
 */
@RestController
@RequestMapping("/tranShort/sentryPost")
public class ShortSentryPostController extends BaseController
{
    @Autowired
    private IShortSentryPostService shortSentryPostService;

    /**
     * 查询哨位管理列表
     */
    @PreAuthorize("@ss.hasPermi('tranShort:sentryPost:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShortSentryPost shortSentryPost)
    {
        startPage();
        List<ShortSentryPost> list = shortSentryPostService.selectShortSentryPostList(shortSentryPost);
        return getDataTable(list);
    }

    /**
     * 导出哨位管理列表
     */
    @PreAuthorize("@ss.hasPermi('tranShort:sentryPost:export')")
    @Log(title = "哨位管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ShortSentryPost shortSentryPost)
    {
        List<ShortSentryPost> list = shortSentryPostService.selectShortSentryPostList(shortSentryPost);
        ExcelUtil<ShortSentryPost> util = new ExcelUtil<ShortSentryPost>(ShortSentryPost.class);
        return util.exportExcel(list, "哨位管理数据");
    }

    /**
     * 获取哨位管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('tranShort:sentryPost:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(shortSentryPostService.selectShortSentryPostById(id));
    }

    /**
     * 新增哨位管理
     */
    @PreAuthorize("@ss.hasPermi('tranShort:sentryPost:add')")
    @Log(title = "哨位管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShortSentryPost shortSentryPost)
    {
        return toAjax(shortSentryPostService.insertShortSentryPost(shortSentryPost));
    }

    /**
     * 修改哨位管理
     */
    @PreAuthorize("@ss.hasPermi('tranShort:sentryPost:edit')")
    @Log(title = "哨位管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShortSentryPost shortSentryPost)
    {
        return toAjax(shortSentryPostService.updateShortSentryPost(shortSentryPost));
    }

    /**
     * 删除哨位管理
     */
    @PreAuthorize("@ss.hasPermi('tranShort:sentryPost:remove')")
    @Log(title = "哨位管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shortSentryPostService.deleteShortSentryPostByIds(ids));
    }
}
